package lhy.autoparts.servlet;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lhy.autoparts.table.EntityTableService;
import lhy.orm.model.EntityData;
import lhy.utils.ReflectUtils;

@WebServlet("/StatsServlet")
public class StatsServlet extends Utf8Servlet{
    @Override
    protected void doGet(HttpServletRequest que, HttpServletResponse pon) {
        super.doGet(que, pon);
        String entityClassName = que.getParameter("entityClassName");
        Class<?> entityClass = ReflectUtils.loadClassByName(entityClassName);
        que.setAttribute("entityClassName",entityClassName);

        EntityData entityData = EntityTableService.getEntityData(entityClassName);
        que.setAttribute("entityData",entityData);

        que.setAttribute("tableContentRequestUrl",que.getContextPath());

        forwardRequest("stat.jsp",que,pon);
    }
}
